package o;

import android.animation.Animator;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.animation.StateListAnimator;
import android.content.res.ColorStateList;
import android.graphics.PorterDuff.Mode;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.GradientDrawable;
import android.graphics.drawable.InsetDrawable;
import android.graphics.drawable.LayerDrawable;
import android.graphics.drawable.RippleDrawable;
import android.os.Build.VERSION;
import android.view.View;
import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi;
import com.google.android.material.internal.VisibilityAwareImageButton;
import java.util.ArrayList;
import java.util.List;

@RequiresApi(21)
public class ars extends arq {
    private InsetDrawable ʽॱ;

    static class b extends GradientDrawable {
        b() {
        }

        public boolean isStateful() {
            return true;
        }
    }

    public ars(VisibilityAwareImageButton visibilityAwareImageButton, ask o_ask) {
        super(visibilityAwareImageButton, o_ask);
    }

    void ˊ(ColorStateList colorStateList, Mode mode, ColorStateList colorStateList2, int i) {
        Drawable layerDrawable;
        this.ॱॱ = gg.ʻ(ॱˊ());
        gg.ॱ(this.ॱॱ, colorStateList);
        if (mode != null) {
            gg.ˋ(this.ॱॱ, mode);
        }
        if (i > 0) {
            this.ʻ = ˎ(i, colorStateList);
            layerDrawable = new LayerDrawable(new Drawable[]{this.ʻ, this.ॱॱ});
        } else {
            this.ʻ = null;
            layerDrawable = this.ॱॱ;
        }
        this.ᐝ = new RippleDrawable(asl.ˎ(colorStateList2), layerDrawable, null);
        this.ʽ = this.ᐝ;
        this.ʼॱ.ॱ(this.ᐝ);
    }

    void ˊ(ColorStateList colorStateList) {
        if (this.ᐝ instanceof RippleDrawable) {
            ((RippleDrawable) this.ᐝ).setColor(asl.ˎ(colorStateList));
        } else {
            super.ˊ(colorStateList);
        }
    }

    void ॱ(float f, float f2, float f3) {
        if (VERSION.SDK_INT == 21) {
            this.ʿ.refreshDrawableState();
        } else {
            StateListAnimator stateListAnimator = new StateListAnimator();
            stateListAnimator.addState(ॱᐝ, ˊ(f, f3));
            stateListAnimator.addState(ʻॱ, ˊ(f, f2));
            stateListAnimator.addState(ॱˎ, ˊ(f, f2));
            stateListAnimator.addState(ᐝॱ, ˊ(f, f2));
            Animator animatorSet = new AnimatorSet();
            List arrayList = new ArrayList();
            arrayList.add(ObjectAnimator.ofFloat(this.ʿ, "elevation", new float[]{f}).setDuration(0));
            if (VERSION.SDK_INT >= 22 && VERSION.SDK_INT <= 24) {
                arrayList.add(ObjectAnimator.ofFloat(this.ʿ, View.TRANSLATION_Z, new float[]{this.ʿ.getTranslationZ()}).setDuration(100));
            }
            arrayList.add(ObjectAnimator.ofFloat(this.ʿ, View.TRANSLATION_Z, new float[]{0.0f}).setDuration(100));
            animatorSet.playSequentially((Animator[]) arrayList.toArray(new Animator[0]));
            animatorSet.setInterpolator(ˋ);
            stateListAnimator.addState(ॱˋ, animatorSet);
            stateListAnimator.addState(ʾ, ˊ(0.0f, 0.0f));
            this.ʿ.setStateListAnimator(stateListAnimator);
        }
        if (this.ʼॱ.ˋ()) {
            ॱ();
        }
    }

    @NonNull
    private Animator ˊ(float f, float f2) {
        Animator animatorSet = new AnimatorSet();
        animatorSet.play(ObjectAnimator.ofFloat(this.ʿ, "elevation", new float[]{f}).setDuration(0)).with(ObjectAnimator.ofFloat(this.ʿ, View.TRANSLATION_Z, new float[]{f2}).setDuration(100));
        animatorSet.setInterpolator(ˋ);
        return animatorSet;
    }

    public float ˋ() {
        return this.ʿ.getElevation();
    }

    void ˎ() {
        ॱ();
    }

    void ˎ(Rect rect) {
        if (this.ʼॱ.ˋ()) {
            this.ʽॱ = new InsetDrawable(this.ᐝ, rect.left, rect.top, rect.right, rect.bottom);
            this.ʼॱ.ॱ(this.ʽॱ);
            return;
        }
        this.ʼॱ.ॱ(this.ᐝ);
    }

    void ॱ(int[] iArr) {
        if (VERSION.SDK_INT != 21) {
            return;
        }
        if (this.ʿ.isEnabled()) {
            this.ʿ.setElevation(this.ˏॱ);
            if (this.ʿ.isPressed()) {
                this.ʿ.setTranslationZ(this.ˋॱ);
                return;
            } else if (this.ʿ.isFocused() || this.ʿ.isHovered()) {
                this.ʿ.setTranslationZ(this.ॱˊ);
                return;
            } else {
                this.ʿ.setTranslationZ(0.0f);
                return;
            }
        }
        this.ʿ.setElevation(0.0f);
        this.ʿ.setTranslationZ(0.0f);
    }

    void ˏ() {
    }

    boolean ᐝ() {
        return false;
    }

    art ʽ() {
        return new arz();
    }

    GradientDrawable ˏॱ() {
        return new b();
    }

    void ˋ(Rect rect) {
        if (this.ʼॱ.ˋ()) {
            float ˎ = this.ʼॱ.ˎ();
            float ˋ = ˋ() + this.ˋॱ;
            int ceil = (int) Math.ceil((double) asn.ˊ(ˋ, ˎ, false));
            int ceil2 = (int) Math.ceil((double) asn.ˏ(ˋ, ˎ, false));
            rect.set(ceil, ceil2, ceil, ceil2);
            return;
        }
        rect.set(0, 0, 0, 0);
    }
}
